@extends('admin.public')

@section('content')
    <div class="col-md-12">
        @if( !empty($pageInfos) )
            <section class="panel panel-default">
                <header class="panel-heading bg-light">
                    <ul class="nav nav-tabs nav-justified">
                        <?php $i = 0; ?>
                        @foreach( $pageInfos as $label=> $value)
                            <li {{ $i==0?'class=active':'' }}>
                                <a href="#{{ $label }}" data-toggle="tab">{{ $value['name'] }}</a>
                            </li>
                            <?php $i++; ?>
                        @endforeach
                    </ul>
                </header>
                <div class="panel-body">
                    <div class="tab-content">
                        <?php $j = 0; ?>
                        @foreach($pageInfos as $label => $value)
                            <div class="tab-pane {{ $j==0?'active':'' }}" id="{{ $label }}">
                                <div class="col-md-12">
                                    <section class="panel panel-default">
                                        <header class="panel-heading">
                                            <a href="{{ route('admin.page.pageinfo_add') }}?label={{ $label }}"
                                               class="btn btn-info"><i
                                                        class="ico icon-plus m-r"></i>{{ $value['name'] }}
                                                信息添加</a>
                                        </header>
                                        <table class="table table-striped m-b-none">
                                            <thead>
                                            <tr>
                                                <th class="col-md-3">信息名称</th>
                                                <th class="col-md-3">超链接标签</th>
                                                <th class="col-md-2">作者</th>
                                                <th class="col-md-2">编辑时间</th>
                                                <th class="col-md-2">操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            @if( !empty($value['data']) )
                                                @foreach($value['data'] as $info)
                                                    <tr>
                                                        <td>
                                                            <a href="{{ route('page',[$info->label_label,$info->id]) }}">
                                                                {{ $info->name }}
                                                            </a>
                                                        </td>
                                                        <td>
                                                            <a href="{{ route('page',[$info->label_label,$info->id]) }}"
                                                               target="_blank">
                                                                {{ '{' }}{ route('page',['{{ $info->label_label }}
                                                                ',{{ $info->id }}])}}
                                                            </a>
                                                        </td>
                                                        <td>{{ $authors[$info->author] }}</td>
                                                        <td>{{ $info->updated_at }}</td>
                                                        <td>
                                                            <button class="btn btn-xs btn-info"
                                                                    data-toggle="popover"
                                                                    data-html="true"
                                                                    data-placement="top"
                                                                    data-content="<div class='scrollable'>
                                                                            {{ $info->label_label }}.blade.php
                                                                            </div>"
                                                                    title="{{ $info->name }}模版"
                                                                    data-original-title="">
                                                                <i class="ico icon-layers"></i>
                                                            </button>
                                                            <a href="{{ route('admin.page.pageinfo_edit',$info->id) }}"
                                                               class="btn btn-xs btn-default">编辑</a>
                                                            <a href="{{ route('admin.page.pageinfo') }}?del={{ $info->id }}"
                                                               class="btn btn-xs btn-danger">删除</a>
                                                        </td>
                                                    </tr>
                                                @endforeach
                                            @else
                                                <tr>
                                                    <td colspan="3" align="center">暂无{{ $value['name'] }}相关信息,请<a
                                                                class="text-danger"
                                                                href="{{ route('admin.page.pageinfo_add') }}?label={{ $label }}">前往添加</a>!
                                                    </td>
                                                </tr>
                                            @endif
                                            </tbody>
                                        </table>
                                    </section>
                                </div>
                            </div>
                            <?php $j++; ?>
                        @endforeach
                    </div>
                </div>
            </section>
        @else
            <div class="alert alert-warning alert-block">
                <button type="button" class="close" data-dismiss="alert">×</button>
                <h4><i class="fa fa-bell-alt"></i>注意!</h4>
                <p>企业信息未添加模块,请<a class="text-danger" href="{{ route('admin.page.pagelabel_add') }}">前往添加</a>!</p>
            </div>
        @endif
    </div>
@endsection

@section('css')
@endsection

@section('js')
@endsection